/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CColumn, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton } from '../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http } from '../../../library/func';
import Icon from '../../../project/style/icon';
import DoHttp from '../../../project/func/http/http';

import time from '../../../project/func/util';

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class Index extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {
			commission:10000,
			list:[],
		}
	}

	/*------------------------------------------------------------------------------------
	 * 生命周期
	 *-----------------------------------------------------------------------------------*/
	// didMount
	componentDidMount() {
		DoHttp.get({
			url:'vip/commissionRecord.php',
			success:(res)=>{

				console.log(res);

				this.setState({
					commission:res.commission,
					list:res.commission_record,
				})
			}

		})
	}
	
	/*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
	// onClick
	onClick = (id, e)=> {
		console.log('onClick: ' + id)
    }
    
    // onRedirect
    onRedirect = (url, e)=> {
        wx.redirectTo({
            url: url
        })
    }

    // onNavigate
    onNavigate = (url, e)=> {

    }

	/*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
	config = {
        navigationBarTitleText: '账户佣金',
        navigationBarBackgroundColor: '#dd2f3c',
        navigationBarTextStyle: '#fff'
    }

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
		return (
			<CPage>
				<CContent>
					
					{/* 金额 */}
					<CColumn bg='#F35953' h='200' x="center" y="center">
						<CText size="14" color="#fff">账户佣金</CText>
						<text style="font-size:30px; color:#fff; font-weight:800; margin-top:20px;">{ this.state.commission.toFixed(2) }</text>
					</CColumn>


					{/* 列表 */}
					<CColumn bg='#fff' h='600' y="top" x="center">

						{this.state.list.map((item, key) =>{
						return (
							<CItemX style="width:90%;" h="50" mt="5" y="center" bb="#eee solid 1px">
								<CBetween>
									<CItemY x="left">
										<text style="font-size:14px">{ item.set_description }</text>
										<text style="color:#666; font-size:12px">{ time.formatTime(item.created,'Y-M-D h:m:s') }</text>
									</CItemY>
									<text style="font-size:14px">{ item.set_commission }</text>
								</CBetween>
							</CItemX>
						)
						})}

					</CColumn>

				</CContent>

			</CPage>
		)
	}
}


